package com.text.config;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MyMVCconfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/admin/login.html").setViewName("login");
        registry.addViewController("/admin/categoryAdd.html").setViewName("categoryAdd");
    }

    @Resource
    MyInterceptor myInterceptor;
    // 添加拦截器管理
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/admin/doLogin")
                .excludePathPatterns("/admin/toLogin")
                .excludePathPatterns("/admin/logout")
                .excludePathPatterns("/admin/login.html")
        ;
    }

}
